﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SachOnlineLibrary.BLL;
using SachOnlineLibrary.Public;
using System.Web.Services;
using System.Web.Script.Services;
public partial class WebUserControlDatHang : System.Web.UI.UserControl
{
    DonDatHangBLL lib = new DonDatHangBLL();
    public static List<DonDatHang> listdondathang;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            gdvDatHang_Load();
        }
    }
    private void gdvDatHang_Load()
    {
        listdondathang = lib.LietKeTatCaDonDatHang();
        gdvDatHang.DataSource = listdondathang;
        gdvDatHang.DataBind();
    }
    protected void gdvDatHang_RowEditing(object sender, GridViewEditEventArgs e)
    {

    }
    protected void cbxHienThi_CheckedChanged(object sender, EventArgs e)
    {
        if (!cbxHienThi.Checked)
        {
            gdvDatHang.DataSource = listdondathang.Where(s => s.TrangThai.Equals("Chưa giao")).ToList();
            gdvDatHang.DataBind();
        }
        else
        {
            gdvDatHang.DataSource = listdondathang;
            gdvDatHang.DataBind();
        }
    }
    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false, XmlSerializeString = false)]
    public static List<ChiTietDatHang> GetOrderDetail(int orderID)
    {
        return listdondathang.SingleOrDefault(d => d.MaPhieu == orderID).ListChiTietDatHang.ToList();
    }

    protected void Button1_Click(object sender, EventArgs e)
    {

    }
    protected void gdvDatHang_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}